#include "singleton.h"
#include <pthread.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>

class TEST : public Singleton<TEST> {
public:
	void setNum(int num) { m_num = num; }
	void print() { printf("m_num:%d\n", m_num); }
	void add(int num) { m_num += num; }
private:
	int m_num;
};

void* fun(void*arg)
{
	TEST* t = TEST::instance();
	t->print();
	t->add(1);

	return NULL;
}

int main()
{
	TEST* t = TEST::instance();
	t->setNum(10);

	pthread_t tid;

	for(int i=0; i<100; ++i)
		pthread_create(&tid, NULL, fun, NULL);


	getchar();

	return 0;
}